<template>
  <div class="registration">
    <div class="top">
      <div class="left">
        {{ detailStore.hospitalDetail.hospital?.hosname }}
      </div>
      <div class="right">
        <svg
          t="1697357063444"
          class="icon"
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="4056"
          width="16"
          height="16"
        >
          <path
            d="M857.28 344.992h-264.832c12.576-44.256 18.944-83.584 18.944-118.208 0-78.56-71.808-153.792-140.544-143.808-60.608 8.8-89.536 59.904-89.536 125.536v59.296c0 76.064-58.208 140.928-132.224 148.064l-117.728-0.192A67.36 67.36 0 0 0 64 483.04V872c0 37.216 30.144 67.36 67.36 67.36h652.192a102.72 102.72 0 0 0 100.928-83.584l73.728-388.96a102.72 102.72 0 0 0-100.928-121.824zM128 872V483.04c0-1.856 1.504-3.36 3.36-3.36H208v395.68H131.36A3.36 3.36 0 0 1 128 872z m767.328-417.088l-73.728 388.96a38.72 38.72 0 0 1-38.048 31.488H272V476.864a213.312 213.312 0 0 0 173.312-209.088V208.512c0-37.568 12.064-58.912 34.72-62.176 27.04-3.936 67.36 38.336 67.36 80.48 0 37.312-9.504 84-28.864 139.712a32 32 0 0 0 30.24 42.496h308.512a38.72 38.72 0 0 1 38.048 45.888z"
            p-id="4057"
          ></path>
        </svg>
        <span>{{
          detailStore.hospitalDetail.hospital?.param.hostypeString
        }}</span>
      </div>
    </div>
    <div class="contend">
      <div class="left">
        <img
          :src="`data:image/jpeg;base64,${detailStore.hospitalDetail.hospital?.logoData}`"
          alt=""
        />
      </div>
      <div class="right">
        <div class="rull">挂号规则</div>
        <div class="regist">
          预约周期：10天 放号时间:{{
            detailStore.hospitalDetail.bookingRule?.releaseTime
          }}
          停挂时间: {{ detailStore.hospitalDetail.bookingRule?.quitTime }}
        </div>
        <div class="address">
          具体位置：{{ detailStore.hospitalDetail.hospital?.param.fullAddress }}
        </div>
        <div class="rout">
          具体路线:{{ detailStore.hospitalDetail.hospital?.route }}
        </div>
        <div class="outId">
          退号时间:就诊前一工作日{{
            detailStore.hospitalDetail.bookingRule?.quitTime
          }}前取消
        </div>
        <div class="ruler">
          预约挂号规则
          <div
            class="rulers"
            v-for="(item, index) in detailStore.hospitalDetail.bookingRule
              ?.rule"
            :key="index"
          >
            {{ item }}
          </div>
        </div>
      </div>
    </div>
    <!-- 科室 -->
    <div class="department">
      <div class="leftNav">
        <ul>
          <li
            v-for="(item, index) in detailStore.hospitalDepartment"
            :key="item.depcode"
            :class="{ active: curntIndex == index }"
            @click="changeIndex(index)"
          >
            {{ item.depname }}
          </li>
        </ul>
      </div>
      <div class="departmentInfo">
        <div
          class="departmentInfoList"
          v-for="(item) in detailStore.hospitalDepartment"
          :key="item.depcode"
        >
          <h1 class="cur">{{ item.depname }}</h1>
          <ul>
            <li v-for="itemList  in item.children" :key="itemList.depcode" @click="showLogin(itemList)">
              {{ itemList.depname }}
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
//引入组合式api
import { ref } from "vue";
//引入仓库
import useDetailStore from "@/store/modules/hospital";
//引入路由器对象
import { useRoute,useRouter } from "vue-router";
//获取仓库
let detailStore = useDetailStore();
//创建路由器对象
let $router = useRouter();
let $route = useRoute();
//定义类名响应式数据
let curntIndex = ref<number>(0);

//索引发生改变的回调
const changeIndex = (index: number) => {
  //修改索引值
  curntIndex.value = index;
 //滚动
    let curArr = document.querySelectorAll('.cur')

    curArr[curntIndex.value].scrollIntoView({
      behavior: 'smooth', // 平滑滚动
      block: 'center', // 开始位置
      inline: 'start' // 内联方向
    })

};
//显示登录对话框
const showLogin = (item:any)=>{
  // UserStore.dialogFormVisible = true;
  //获取当前路由信息
  let hoscode = $route.query.hoscode;
  let depcode = item.depcode;
  //路由跳转
  $router.push({
    path:'registration_step1',
    query:{
      hoscode,
      depcode
    }
  })
}
</script>

<style scoped lang="scss">
.registration {
  .top {
    display: flex;
    .left {
      font-size: 35px;
      font-weight: 900;
      margin-right: 10px;
    }
    .right {
      height: 40px;
      line-height: 40px;
    }
  }
  .contend {
    display: flex;
    margin-top: 30px;
    .left {
      width: 100px;
      img {
        width: 100px;
        height: 100px;
        border-radius: 50%;
      }
    }
    .right {
      flex: 1;
      margin-top: 20px;
      margin-left: 30px;
      .regist,
      .address,
      .rout,
      .outId {
        margin-top: 10px;
      }
      .ruler {
        margin: 10px 0px;
        .rulers {
          margin: 10px 0px;
        }
      }
    }
  }
  .department {
    margin-top: 30px;
    width: 1100px;
    height: 800px;
    display: flex;

    .leftNav {
      width: 100px;
      height: 100%;
      ul {
        background: rgb(248, 248, 248);
        display: flex;
        flex-direction: column;

        width: 100%;
        height: 100%;

        li {
          flex: 1;
          font-size: 14px;
          line-height: 60px;
          text-align: center;
          transition: all 0.3s;
          &.active {
            border-left: 1px solid red;
            color: red;
            background-color: white;
          }
        }

        li:hover {
          //鼠标变小手
          cursor: pointer;
        }
      }
    }
    .departmentInfo {
      width: 100%;
      height: 100%;
      overflow: auto;
      margin-left: 30px;
      flex: 1;
      background: rgb(248, 248, 248);
      //隐藏滚动条
      &::-webkit-scrollbar {
        display: none;
      }
      .departmentInfoList {
      margin-top: 20px;
      .cur {
        color: #6a6969;
        font-size: 16px;
        font-weight: 900;
      }
        ul {
          display: flex;
          flex-wrap: wrap;
          li {
            width: 33%;
            line-height: 30px;
          }
        }
      }
    }
  }
}
</style>
